<template>
  <div>
    <van-tabs v-model="active" @click="change">
      <van-tab
        v-for="item in list"
        :key="item.id"
        :title="item.title"
        :name="item.id"
      ></van-tab>
    </van-tabs>

    <van-card
      v-for="item in children"
      :key="item.cid"
      :price="item.price"
      :title="item.title"
      :thumb="item.img"
    />
  </div>
</template>
<script>
export default {
  data() {
    return {
      list: [],
      active: 0,
      children: [],
    };
  },
  mounted() {
    this.$axios.get("/aaa.json").then((res) => {
      this.list = res.data.data;
    });
  },
  methods: {
    change(id) {
      console.log(id);
      this.list.forEach((item) => {
        if (item.id == id) {
          this.children = item.children;
        }
      });
    },
  },
};
</script>
